//
//  HWCustomerCodingViewController.m
//  嗨文
//
//  Created by 响当当 on 6/10/19.
//  Copyright © 2019 dongzheng. All rights reserved.
//

#import "HWCustomerCodingViewController.h"
#import "HWCommonWebViewController.h"

@interface HWCustomerCodingViewController ()
@property (nonatomic, strong)UIImageView *bgImageView;//背景图
@property (nonatomic, strong)UIView *maskView;//蒙版
@property (nonatomic, strong)UIView *bgView;//
@end

@implementation HWCustomerCodingViewController

- (UIImageView *)bgImageView
{
    if (!_bgImageView)
    {
        _bgImageView = [[UIImageView alloc]initWithFrame:self.view.bounds];
        _bgImageView.image = [UIImage imageNamed:@"launch"];
    }
    return _bgImageView;
}

- (UIView *)maskView
{
    if (!_maskView)
    {
        _maskView = [[UIView alloc]initWithFrame:self.view.bounds];
        _maskView.backgroundColor = [UIColor colorWithHue:0 saturation:0 brightness:0 alpha:0.65];
    }
    return _maskView;
}

- (UIView *)bgView
{
    if (!_bgView)
    {
        _bgView = [[UIView alloc] initWithFrame:CGRectMake(50*kUIScaleBasePlus,SCREEN_HEIGHT/2-115*kUIScaleBasePlus,SCREEN_WIDTH-100*kUIScaleBasePlus,230*kUIScaleBasePlus)];
        _bgView.backgroundColor = [UIColor whiteColor];
        _bgView.layer.masksToBounds = YES;
        _bgView.layer.cornerRadius = 10;
        
        UILabel *titleLabel = [HWUtilties creatLabelWithFrame:CGRectMake(0,10*kUIScaleBasePlus,_bgView.frame.size.width,20*kUIScaleBasePlus)
                                                 textAligment:NSTextAlignmentCenter
                                                     textClor:LCHexColor(0x000000)
                                                     textFont:16*kUIScaleBasePlus];
        titleLabel.text = @"用户隐私保护提示";
        [_bgView addSubview:titleLabel];
        
        UILabel *contextLabel = [HWUtilties creatLabelWithFrame:CGRectMake(10*kUIScaleBasePlus,CGRectGetMaxY(titleLabel.frame)+5*kUIScaleBasePlus,_bgView.frame.size.width-20*kUIScaleBasePlus,0)
                                                   textAligment:NSTextAlignmentLeft
                                                       textClor:LCHexColor(0x333333)
                                                       textFont:14*kUIScaleBasePlus];
        contextLabel.numberOfLines = 0;
        contextLabel.text = @"       嗨文为了更好的保护您的隐私和个人信息安全，根据国家相关规定和标准更新了《嗨小说用户协议》和《嗨小说用户隐私保护政策》，请你仔细阅读后并了解";
        [contextLabel sizeToFit];
        [_bgView addSubview:contextLabel];

        UIButton *codingBtn = [HWUtilties creatButtonWithFrame:CGRectMake(10*kUIScaleBasePlus,CGRectGetMaxY(contextLabel.frame)+15*kUIScaleBasePlus,_bgView.frame.size.width-20*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                                  textAligment:NSTextAlignmentLeft
                                                          text:@"《嗨小说用户协议》"
                                                      textClor:JSAMainColor
                                                     buttonBGC:[UIColor clearColor]
                                                      textFont:14*kUIScaleBasePlus
                                                        target:self
                                                        method:@selector(haiwenConding)];
        [_bgView addSubview:codingBtn];
        
        UIButton *privacyBtn = [HWUtilties creatButtonWithFrame:CGRectMake(10*kUIScaleBasePlus,CGRectGetMaxY(codingBtn.frame)+5*kUIScaleBasePlus,_bgView.frame.size.width-20*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                                  textAligment:NSTextAlignmentLeft
                                                          text:@"《嗨小说用户隐私保护政策》"
                                                      textClor:JSAMainColor
                                                     buttonBGC:[UIColor clearColor]
                                                      textFont:14*kUIScaleBasePlus
                                                        target:self
                                                        method:@selector(privacyClick)];
        [_bgView addSubview:privacyBtn];
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(privacyBtn.frame)+10*kUIScaleBasePlus, _bgView.frame.size.width,1*kUIScaleBasePlus)];
        lineView.backgroundColor = JSALineColor;
        [_bgView addSubview:lineView];
        
        UIButton *cancelBtn = [HWUtilties creatButtonWithFrame:CGRectMake(0,CGRectGetMaxY(lineView.frame),50*kUIScaleBasePlus,40*kUIScaleBasePlus)
                                                 textAligment:NSTextAlignmentCenter
                                                         text:@"不同意"
                                                     textClor:JSAMainColor
                                                    buttonBGC:[UIColor clearColor]
                                                     textFont:16*kUIScaleBasePlus
                                                       target:self
                                                       method:@selector(agreeClick)];
        [_bgView addSubview:cancelBtn];
        
//        UIButton *agreeBtn = [HWUtilties creatButtonWithFrame:CGRectMake(CGRectGetMaxX(cancelBtn.frame),CGRectGetMaxY(lineView.frame),_bgView.frame.size.width/2,40*kUIScaleBasePlus)
//                                                   textAligment:NSTextAlignmentCenter
//                                                           text:@"同意"
//                                                       textClor:JSAMainColor
//                                                      buttonBGC:[UIColor clearColor]
//                                                       textFont:16*kUIScaleBasePlus
//                                                         target:self
//                                                         method:@selector(agreeClick)];
//        [_bgView addSubview:agreeBtn];
        
    }
    return _bgView;
}


- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.view addSubview:self.bgImageView];
    [self.view addSubview:self.maskView];
    [self.view addSubview:self.bgView];
}

- (void)agreeClick
{
    if (self.agreeCodingBlock)
    {
        self.agreeCodingBlock();
    }
}

- (void)haiwenConding
{
    [HWUtilties pushWebWithUrl:[NSString stringWithFormat:@"%@%@",WEBCOMME_HOST,@"/userAgreement"] title:@"用户协议" toUrl:nil toId:nil];
}

- (void)privacyClick
{
    [HWUtilties pushWebWithUrl:[NSString stringWithFormat:@"%@%@",WEBCOMME_HOST,@"/privacyPolicy"] title:@"用户隐私政策" toUrl:nil toId:nil];
}
@end
